﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Toasts.Models;

namespace Toasts.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }

       
        public ActionResult Edit()
        {
            return View();
        }

        public ActionResult Submit()
        {
            return View();
        }

        //
        // POST: /Home/Submit

        [HttpPost]
        public ActionResult Submit(Submission submission)
        {
            if (ModelState.IsValid)
            {
                using (Repository db = new Repository())
                {
                    db.Submissions.Add(submission);
                    db.SaveChanges();
                    return RedirectToAction("Index");
                }
            }

            return View(submission);
        }
    }
}
